
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0794
 * @Author : WangRuoyu 
 * @Date : 2023/9/13 19:24
 */

#include "iostream"
#include "vector"
#include "algorithm"

using namespace std;

void div(vector<int> &a, int b, vector<int> &c, int &r) {
    for (int i = a.size() - 1; i >= 0; --i) {
        int tmp = r * 10 + a[i];
        c.push_back(tmp / b);
        r = tmp % b;
    }
    reverse(c.begin(), c.end());
    while (c.size() > 1 && c.back() == 0) c.pop_back();
}

int main() {
    string sa;
    vector<int> a;
    int b;

    cin >> sa >> b;

    for (int i = sa.size() - 1; i >= 0; --i) {
        a.push_back(sa[i] - '0');
    }

    vector<int> c;
    int r = 0;

    div(a, b, c, r);

    for (int i = c.size() - 1; i >= 0; --i) {
        printf("%d", c[i]);
    }
    printf("\n%d", r);

    return 0;
}